//
//  BaseVC.m
//  Graduate
//
//  Created by xp on 16/8/2.
//  Copyright © 2016年 mingthink. All rights reserved.
//

#import "BaseVC.h"

@interface BaseVC ()

@end

@implementation BaseVC

- (void)viewDidLoad {
    [super viewDidLoad];
    //[self initBaseViewController];
    [self createBackBtn];
}

- (void)initBaseViewController {
    //self.view.backgroundColor = GET_HEX_COLOR(TABLE_SEPARATOR_CONTENT);
//    self.navigationController.interactivePopGestureRecognizer.delegate=nil;
//    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    //self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
-(void)createBackBtn {
    self.backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    //_backBtn.tag=200;
    //[self.backBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    [self.backBtn setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
    //UIImage *image = [[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    //[self.backBtn setImage:image forState:UIControlStateNormal];
    //self.backBtn.imageView.tintColor = [UIColor whiteColor];
    [self.backBtn.imageView setContentMode:UIViewContentModeLeft];
    [self.backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.navView addSubview:self.backBtn];
    self.backBtn.sd_layout.leftSpaceToView(self.navView,20).heightIs(40).widthIs(40).centerYEqualToView(self.navTitleL);
    self.backBtn.imageView.sd_layout.leftSpaceToView(self.backBtn,0).widthIs(30).heightIs(30).centerYEqualToView(self.backBtn);
}
- (void)setNoBack:(BOOL)noBack {
    _noBack = noBack;
    self.backBtn.hidden = _noBack;
}
- (void)showRightBtnWithImage:(NSString *)name {
    if (_btn_right) {
        [_btn_right setImage:[UIImage imageNamed:name] forState:UIControlStateNormal];
        return;
    }
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *image = [[UIImage imageNamed:name] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    [rightBtn setImage:image forState:UIControlStateNormal];
    rightBtn.imageView.tintColor = [UIColor whiteColor];
    [rightBtn.imageView setContentMode:UIViewContentModeRight];
    [rightBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    [rightBtn addTarget:self action:@selector(rightClick:) forControlEvents:UIControlEventTouchUpInside];
    rightBtn.titleLabel.font = GET_SYSTEM_FONT(16);
    [self.navView addSubview:rightBtn];
    _btn_right = rightBtn;
    _btn_right.sd_layout.rightSpaceToView(self.navView,0).heightIs(40).widthIs(50).centerYEqualToView(self.navTitleL);
    _btn_right.imageView.sd_layout.rightSpaceToView(_btn_right,CELL_LEFT_MARGIN + 2).widthIs(40).heightIs(40).centerYEqualToView(_btn_right);
}
- (void)showRightBtnWithText:(NSString *)aName {
    if (_btn_right) {
        [_btn_right setTitle:aName forState:UIControlStateNormal];
        return;
    }
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setTitle:aName forState:UIControlStateNormal];
    rightBtn.titleLabel.font = GET_SYSTEM_FONT(16);
    [rightBtn setTitleColor:GET_HEX_COLOR(CELL_LABLE_BORDER_RED) forState:UIControlStateNormal];
     [rightBtn setTitleColor:GET_HEX_COLOR(TEXT_GRAY) forState:UIControlStateDisabled];
    [rightBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    [rightBtn addTarget:self action:@selector(rightClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.navView addSubview:rightBtn];
    _btn_right = rightBtn;
    _btn_right.sd_layout.rightSpaceToView(self.navView,0).heightIs(40).widthIs(150).centerYEqualToView(self.navTitleL);
    _btn_right.titleLabel.sd_layout.rightSpaceToView(_btn_right,CELL_LEFT_MARGIN + 2).widthIs(80).heightIs(40).centerYEqualToView(_btn_right);
}
//
//- (void)rightClick:(UIButton*)selBtn{
//    
//}
//
-(void)back {
    [self.navigationController popViewControllerAnimated:YES];
}

//NewsId=20170104084251656723391156091444&ObjectId=20170104084251656723391156091444
-(NSMutableDictionary*)getParamStrDic:(NSString*)paramStr{
    NSMutableDictionary *dic_m = NSMutableDictionary.new;
    if (!paramStr || paramStr.length == 0){
        return dic_m;
    }else{
        NSArray *arr_param = [paramStr componentsSeparatedByString:@"&"];
        for (int i=0;i<arr_param.count;i++){
            NSArray *arr_dic = [arr_param[i] componentsSeparatedByString:@"="];
            [dic_m setObject:arr_dic[1] forKey:arr_dic[0]];
        }
        return dic_m;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
